<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRequestsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('requests', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('request_id')->index();
            $table->string('auth_id')->default(0)->index();
            $table->string('auth_name')->default('')->index();
            $table->string('method');
            $table->string('url');
            $table->json('params')->comment('全部请求参数');
            $table->json('system_info')->nullable();
            $table->string('ip');
            $table->text('agent');
            $table->text('referer')->nullable();
            $table->smallInteger('status')->default(0);
            $table->string('province')->nullable();
            $table->string('city')->nullable();
            $table->string('district')->nullable();
            $table->text('location_description')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('requests');
    }
}
